#pragma once
#include <string>
#include <sstream>
#include <unordered_map>
#include "CarCmd.h"
#include "TemplateName.h"
#include "IdManager.h"
#include "MapFunc.h"
#include "Component.h"
#include "TemplateCenter.h"

using namespace std;

/**
 * 智能小车
 */
class SmartCar {
    friend class CarController;
    private:
        // 智能小车编号
        string id;
        // 组件表
        unordered_map<string,Component*> componentMap;
        SmartCar();
        SmartCar(const string _id);
        SmartCar(SmartCar* const car);
        string processInfoToCmd(string componentName,string info);
    public:
        ~SmartCar();
        string getId();
        Component* addComponent(string name);
        Component* addComponent(Component* component);
        Component* addComponent(const string name,Component* component);
        bool deleteComponent(string name);
        int getComponentCount();
        void listAllComponent(Component* (&componentList)[]);
        string toString();

        void updateInfo();
};